package com.ningxia.water.service.impl;

import com.ningxia.water.entity.ZtVillageInfo;
import com.ningxia.water.mapper.ZtVillageInfoMapper;
import com.ningxia.water.service.IZtVillageInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningxia.water.vo.out.ReportVo;
import com.ningxia.water.vo.out.ZonePidVo;
import com.ningxia.water.vo.out.ZoneVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hz
 * @since 2021-05-14
 */
@Service
public class ZtVillageInfoServiceImpl extends ServiceImpl<ZtVillageInfoMapper, ZtVillageInfo> implements IZtVillageInfoService {

    @Autowired
    private ZtVillageInfoMapper villageInfoMapper;

    @Override
    public List<ZoneVo> getVillageInfos() {
        return villageInfoMapper.getVillageInfos();
    }

    @Override
    public List<ReportVo> getVillageReport(String type, String currentTime) {
        /**
         * 根据传入type类型判断，年报，月报，日报
         */

        if (type.equals("year")) {
            // 年报
            return villageInfoMapper.getVillageReportByYear(currentTime);
        } else if (type.equals("month")) {
            // 月报
            return villageInfoMapper.getVillageReportByMonth(currentTime);
        } else if (type.equals("day")) {
            // 日报
            return villageInfoMapper.getVillageReportByDay(currentTime);
        }
        return null;
    }

    @Override
    public List<ZonePidVo> getVillageRelationship() {
        return villageInfoMapper.getVillageRelationship();
    }
}
